﻿@using StackExchange.Opserver.Controllers
@using StackExchange.Opserver.Data.Redis
@using StackExchange.Opserver.Views.Redis
@model DashboardModel
@{
    Layout = "~/Views/Shared/Master.cshtml";
    this.SetPageTitle("Redis Dashboard");
    this.SetTopNodes(RedisModule.Instances, "Redis Servers", Model.CurrentInstance);
}
@helper TabLink(RedisViews view, string action, string name, bool includeParams = true)
{
    <li class="@(Model.View == view ? "active" : null)">
        <a href="@Url.Action(action, includeParams && Model.CurrentInstance != null ? new { node = Model.CurrentInstance.HostAndPort } : null)">@name</a>
    </li>
}
@section head {
    <script>
        $(function() {
            Status.Dashboard.init({ refresh: @(Model.Refresh ? 5 : 0) });
            Status.Redis.init({ node: '@(Model.CurrentInstance?.Host.HostName ?? "")', port: '@(Model.CurrentInstance?.Port.ToString() ?? "")' });
        });
    </script>
}
<ul class="nav nav-tabs nav-tabs-right">
    @TabLink(RedisViews.All, nameof(RedisController.Dashboard), "dashboard", false)
    @TabLink(RedisViews.Instance, nameof(RedisController.Instance), "instance")
</ul>
<div>
    @if (Model.View == RedisViews.Instance && Model.CurrentInstance == null)
    {
        @Html.Partial("Instance.Selector")
    }
    @RenderBody()
</div>